package com.kly.user.task;

import cn.hutool.core.net.NetUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.fqgj.common.api.Response;
import com.fqgj.common.utils.CollectionUtils;
import com.fqgj.common.utils.HttpUtil;
import com.fqgj.common.utils.StringUtils;
import com.fqgj.log.factory.LogFactory;
import com.fqgj.log.interfaces.Log;
import com.google.common.collect.Maps;
import com.google.common.eventbus.AsyncEventBus;
import com.kly.dto.TOrderDto;
import com.kly.enums.ParameterTypeEnum;
import com.kly.service.TOrderService;
import com.kly.user.chatterService.ChatService;
import com.kly.user.db.dao.*;
import com.kly.user.db.entity.*;
import com.kly.user.dto.AddWlmReq;
import com.kly.user.dto.RecommendUserDto;
import com.kly.user.dto.chatter.request.ConversationReq;
import com.kly.user.enums.AppEnum;
import com.kly.user.enums.ConversationType;
import com.kly.user.enums.OnlineStatus;
import com.kly.user.eventbus.ActionEnum;
import com.kly.user.eventbus.Event;
import com.kly.user.service.AsyncSendMsgService;
import com.kly.user.serviceImpl.OtherServiceImpl;
import com.kly.user.serviceImpl.WlmServiceImpl;
import com.kly.user.utils.ServiceUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;


/**
 * flash chat 下发
 */
@Component
public class SendFlashMsgTask {

    private static Log logger = LogFactory.getLog(SendFlashMsgTask.class);

    @NacosValue(value = "${task.job.executor.ip}", autoRefreshed = true)
    private String taskJobExecutor;

    private String localIP = NetUtil.getLocalhostStr();

    @Autowired
    private UserDao userDao;

    @Autowired
    private UserFcConfigDao userFcConfigDao;

    @Autowired
    private UserMsgDao userMsgDao;

    @Resource
    private TOrderService tOrderService;

    @Autowired
    private WlmServiceImpl wlmService;

    @Autowired
    private OtherServiceImpl otherService;

    @Resource
    UserGreetingCommonContentDao userGreetingCommonContentDao;

    @Resource
    UserCommonLogDao commonLogDao;

    @Resource
    AsyncEventBus pushEventBus;

    @Resource
    ChatService chatService;

    @Resource
    UserWlmDao userWlmDao;

    @Resource
    private AsyncSendMsgService asyncSendMsgService;

    @Resource
    private IssueFcRecordDao issueFcRecordDao;


    /**
     * 每30秒处理一次 flash chat 下发
     */
    @Scheduled(fixedDelay = 60000)
    public void execute() {

        if (!taskJobExecutor.contains(localIP)) {
            logger.info("=============SendFlashMsgTask, currentLocalAddress:{}, onlyExecuteTaskIn:{}", localIP, taskJobExecutor);
            return;
        }

//        userWlmDao.listUserWlmList()

    }
}
